/*    */ 
/*    */ 
/*    */ import java.awt.AWTException;
/*    */ import java.awt.Robot;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintStream;
/*    */ 
/*    */ public class SystemOperations
/*    */ {
/*    */   public boolean isWin;
/*    */   public static final int LOGOFF = 1;
/*    */   public static final int LOCK = 2;
/*    */   public static final int RESTART = 3;
/*    */   public static final int SLEEP = 4;
/*    */   public static final int SHUTDOWN = 5;
/*    */ 
/*    */   public void doSystemOperation(int commandcode)
/*    */     throws IOException, AWTException
/*    */   {
/* 17 */     String myCommand = null;
/* 18 */     String operatingSystem = System.getProperty("os.name");
/* 19 */     if (operatingSystem.contains("Win")) {
/* 20 */       this.isWin = true;
/* 21 */       System.out.println("Win");
/*    */     }
/* 23 */     switch (commandcode) {
/*    */     case 1:
/* 25 */       if (this.isWin) myCommand = "shutdown -l -f"; else
/* 26 */         myCommand = "sudo logout";
/* 27 */       break;
/*    */     case 3:
/* 29 */       if (this.isWin) myCommand = "shutdown -r"; else
/* 30 */         myCommand = "sudo shutdown -r";
/* 31 */       break;
/*    */     case 4:
/* 33 */       if (this.isWin) myCommand = "rundll32 powrprof.dll,SetSuspendState"; else
/* 34 */         myCommand = "sudo shutdown -s";
/* 35 */       break;
/*    */     case 2:
/* 37 */       if (!this.isWin) break; lockWin();
/*    */     case 5:
/* 39 */       if (this.isWin) myCommand = "shutdown -s"; else {
/* 40 */         myCommand = "sudo shutdown -h now";
/*    */       }
/*    */     }
/* 43 */     if (myCommand != null)
/* 44 */       Runtime.getRuntime().exec(myCommand); 
/*    */   }
/*    */ 
/*    */   public void lockWin() throws AWTException {
/* 47 */     Robot robot = new Robot();
/* 48 */     robot.keyPress(157);
/* 49 */     robot.keyPress(76);
/* 50 */     robot.keyRelease(157);
/* 51 */     robot.keyRelease(76);
/*    */ 
/* 61 */     System.out.println("lock");
/*    */   }
/*    */ }
